﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DAL.Log4Net
{
   public class LogHelper
    {
        /// <summary>
        /// 输出错误日志到数据库
        /// </summary>
        /// <param name="t"></param>
        /// <param name="ex"></param>
        public static void WriteErrorLog(Type t, Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Error(new LogContent("127.0.0.1", "sysadmin", "运行异常", ex.Message));   
        } 
        /// <summary>
        /// 输出常规日志到数据库
        /// </summary>
        /// <param name="t">Logger</param>
        /// <param name="ipAddress">IP</param>
        /// <param name="userName">用户名</param>
        /// <param name="actionClik">操作名</param>
        /// <param name="descrption">描述</param>
        
        public static void WriteInfoLog(Type t,String ipAddress,String userName,String actionClik,String descrption)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Info(new LogContent(ipAddress, userName, actionClik, descrption));
        }
        /// <summary>
        /// 输出警告日志到数据库
        /// </summary>
        /// <param name="t">Logger</param>
        /// <param name="ipAddress">IP</param>
        /// <param name="userName">用户名</param>
        /// <param name="actionClik">操作名</param>
        /// <param name="descrption">描述</param>
        public static void WriteWarnLog(Type t, String ipAddress, String userName, String actionClik, String descrption)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Info(new LogContent(ipAddress, userName, actionClik, descrption));
        }
    }
}
